package org.keyboardman.service;

import org.keyboardman.mapper.ResourceMapper;
import org.keyboardman.mapper.UserMapper;
import org.keyboardman.model.Resource;
import org.keyboardman.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by longky on 2017/3/28.
 */
@Service
public class UserService {
    @Autowired(required = false)
    private UserMapper userMapper;
    @Autowired(required = false)
    private ResourceMapper resourceMapper;
public User getUserbyId(long id){
return userMapper.selectByPrimaryKey(id);
}

    public int addUser(User user) {

        return userMapper.insert(user);
    }

    public User getUserbyUserName(String userName) {

    return userMapper.selectByUserName(userName);
    }

    public List<Resource> getResourcebyUserName(String userName) {

        return resourceMapper.selectByUserName(userName);
    }
}
